﻿var DateTime =
{
    Days: ['Chủ Nhật', 'Thứ Hai', 'Thứ Ba', 'Thứ Tư', 'Thứ Năm', 'Thứ Sáu', 'Thứ Bảy'],
    Months: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
    FixNum: function(x) {
        if (x < 10) { x = "0" + x; }
        return x;
    },
    Show: function(objid) {
        var today = new Date();
        var day = DateTime.Days[today.getDay()];
        var date = today.getDate();
        var month = DateTime.Months[today.getMonth()];
        var year = today.getFullYear();

        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();

        var at = 'am';
        if (h > 12) { h -= 12; at = 'pm'; }
        if (h == 0) h = 12;

        date = DateTime.FixNum(date);
        m = DateTime.FixNum(m);
        s = DateTime.FixNum(s);

        var obj = document.getElementById(objid);
        obj.innerHTML = day + " " + date + "/" + month + "/" + year + " " + h + ":" + m + ":" + s + at;
        setTimeout("DateTime.Show('" + objid + "')", 500);
    },
    ShowDate: function(objid) {
        var today = new Date();
        var day = DateTime.Days[today.getDay()];
        var date = today.getDate();
        var month = DateTime.Months[today.getMonth()];
        var year = today.getFullYear();

        date = DateTime.FixNum(date);

        var obj = document.getElementById(objid);
        obj.innerHTML = day + " " + date + "/" + month + "/" + year;
    }
}